// Packages go here.
package calcSrc;
import calcSrc.NIMCruncher;

//Import statements go here.
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;

// GUI class.  This will be called by the main in the NIMCalc class.
public class NIMGUI extends JFrame {
	// Integers to define the size of things.  These should never change.

	private static final int ORE_PANEL_WIDTH = 162;
	private static final int ORE_PANEL_HEIGHT = 150;
	private static final int BUTTONBOX_PANEL_WIDTH = 125;
	private static final int BUTTONBOX_PANEL_HEIGHT = 233;
	private static final int RESULT_PANEL_WIDTH = 650;
	private static final int RESULT_PANEL_HEIGHT = 100;
	private static final int LABEL_WIDTH = 75;
	private static final int LABEL_HEIGHT = 50;
	private static final int BOX_WIDTH = 75;
	private static final int BOX_HEIGHT = 50;	
	
	// Menu things.	
	private JMenuBar myMenu;
	private JMenu fileMenu;
	private JMenu optionMenu;
	private JMenu helpMenu;
	private JMenu stations;
	private JMenuItem calculate;
	private JMenuItem fileExit;
	private JMenuItem helpAbout;
	private JRadioButtonMenuItem halibai;
	private JRadioButtonMenuItem sonama;
	private JRadioButtonMenuItem turba;
	private JRadioButtonMenuItem inisIlix;
	private JRadioButtonMenuItem hilaban;
	private JRadioButtonMenuItem kothe;
	private JRadioButtonMenuItem aunia;
	private JCheckBoxMenuItem hauler;
	
	/* Panel declarations.  There have to be panels for the radio buttons, check boxes,
	 * results, and all of the individual ore types (there are sixteen different types of ores).
	 */
	private JPanel overallLayoutPanel;
	private JPanel centerLayoutPanel;
	private JPanel picturePanel;
	private JPanel resultPanel;
	private JPanel veldPanel;
	private JPanel scordPanel;
	private JPanel plagPanel;
	private JPanel pyroPanel;
	private JPanel omberPanel;
	private JPanel kernPanel;
	private JPanel jaspPanel;
	private JPanel hemoPanel;
	private JPanel hedbPanel;
	private JPanel gneiPanel;
	private JPanel dochPanel;
	private JPanel spodPanel;
	private JPanel crokPanel;
	private JPanel bistPanel;
	private JPanel arkoPanel;
	private JPanel mercPanel;
	
	/* Label declarations.  There is one label per subset of ore, and there are three subsets
	 * per ore type.  That's 48 labels.  There must also be one per mineral type to identify them.
	 * The 48 different ore labels are initialized here so that I don't have to retype all of that in
	 * a constructor somewhere else in the code. */
	private final JLabel veldL = new JLabel("Veldspar");
	private final JLabel conVeldL = new JLabel("Cocentrated Veldspar");
	private final JLabel denVeldL = new JLabel("Dense Veldspar");
	private final JLabel scordL = new JLabel("Scordite");
	private final JLabel conScordL = new JLabel("Condensed Scordite");
	private final JLabel masScordL = new JLabel("Massive Scordite");
	private final JLabel plagL = new JLabel("Plagioclase");
	private final JLabel azuPlagL = new JLabel("Azure Plagioclase");
	private final JLabel ricPlagL = new JLabel("Rich Plagioclase");
	private final JLabel pyroL = new JLabel("Pyroxeres");
	private final JLabel solPyroL = new JLabel("Solid Pyroxeres");
	private final JLabel visPyroL = new JLabel("Viscous Pyroxeres");
	private final JLabel omberL = new JLabel("Omber");
	private final JLabel silOmberL = new JLabel("Silvery Omber");
	private final JLabel golOmberL = new JLabel("Golden Omber");
	private final JLabel kernL = new JLabel("Kernite");
	private final JLabel lumKernL = new JLabel("Luminous Kernite");
	private final JLabel firKernL = new JLabel("Fiery Kernite");
	private final JLabel jaspL = new JLabel("Jaspet");
	private final JLabel purJaspL = new JLabel("Pure Jaspet");
	private final JLabel priJaspL = new JLabel("Pristine Jaspet");
	private final JLabel hemoL = new JLabel("Hemorphite");
	private final JLabel vivHemoL = new JLabel("Vivid Hemorphite");
	private final JLabel radHemoL = new JLabel("Radiant Hemorphite");
	private final JLabel hedbL = new JLabel("Hedbergite");
	private final JLabel vitHedbL = new JLabel("Vitreous Hedbergite");
	private final JLabel glaHedbL = new JLabel("Glazed Hedbergite");
	private final JLabel gneiL = new JLabel("Gneiss");
	private final JLabel iriGneiL = new JLabel("Iridescent Gneiss");
	private final JLabel priGneiL = new JLabel("Prismatic Gneiss");
	private final JLabel dochL = new JLabel("Dark Ochre");
	private final JLabel onyOchL = new JLabel("Onyx Ochre");
	private final JLabel obsOchL = new JLabel("Obsidian Ochre");
	private final JLabel spodL = new JLabel("Spodumain");
	private final JLabel briSpodL = new JLabel("Bright Spodumain");
	private final JLabel gleSpodL = new JLabel("Gleaming Spodumain");
	private final JLabel crokL = new JLabel("Crokite");
	private final JLabel shaCrokL = new JLabel("Sharp Crokite");
	private final JLabel cryCrokL = new JLabel("Crystalline Crokite");
	private final JLabel bistL = new JLabel("Bistot");
	private final JLabel triBistL = new JLabel("Triclinic Bistot");
	private final JLabel monBistL = new JLabel("Monoclinic Bistot");
	private final JLabel arkoL = new JLabel("Arkonor");
	private final JLabel criArkoL = new JLabel("Crimson Arkonor");
	private final JLabel priArkoL = new JLabel("Prime Arkonor");
	private final JLabel mercL = new JLabel("Mercoxit");
	private final JLabel magMercL = new JLabel("Magma Mercoxit");
	private final JLabel vitMercL = new JLabel("Vitreous Mercoxit");
	private final JLabel tritN = new JLabel("Tritanium Price:");
	private final JLabel pyerN = new JLabel("Pyerite Price:");
	private final JLabel mexaN = new JLabel("Mexallon Price:");
	private final JLabel isogN = new JLabel("Isogen Price:");
	private final JLabel nocxN = new JLabel("Nocxium Price:");
	private final JLabel zydrN = new JLabel("Zydrine Price:");
	private final JLabel megaN = new JLabel("Megacyte Price:");
	private final JLabel morpN = new JLabel("Morphite Price:");
	private final JLabel minerPayN = new JLabel("Miner Pay:");
	private final JLabel haulerPayN = new JLabel("Hauler Pay:");
	
	/* These are just the labels for the different minerals. */	
	private JLabel tritL  = new JLabel("Tritanium:");
	private JLabel pyerL = new JLabel("Pyerite:");
	private JLabel mexaL = new JLabel("Mexallon:");
	private JLabel isogL = new JLabel("Isogen:");
	private JLabel nocxL = new JLabel("Nocxium:");
	private JLabel zydrL = new JLabel("Zydrine:");
	private JLabel megaL = new JLabel("Megacyte:");
	private JLabel morpL = new JLabel("Morphite:");	
	
	/* These are public so that the Cruncher class can change them as necessary.
	 * They are where the resulting amounts of minerals produced are shown.
	*/
	public JLabel tritRL = new JLabel("0");
	public JLabel pyerRL = new JLabel("0");
	public JLabel mexaRL = new JLabel("0");
	public JLabel isogRL = new JLabel("0");
	public JLabel nocxRL = new JLabel("0");
	public JLabel zydrRL = new JLabel("0");
	public JLabel megaRL = new JLabel("0");
	public JLabel morpRL = new JLabel("0");	
	public JLabel minerPayRL = new JLabel("0");
	public JLabel haulerPayRL = new JLabel("0");
	
	/* Text box declarations.  There is one text box per subset of ore, and there are three subsets
	 * per ore type.  That's 48 text boxes.  There must also be one per mineral type to input the 
	 * price per unit mineral.
	 */
	private JTextField veldB = new JTextField();	
	private JTextField conVeldB = new JTextField();
	private JTextField denVeldB = new JTextField();
	private JTextField scordB = new JTextField();
	private JTextField conScordB = new JTextField();
	private JTextField masScordB = new JTextField();
	private JTextField plagB = new JTextField();
	private JTextField azuPlagB = new JTextField();
	private JTextField ricPlagB = new JTextField();
	private JTextField pyroB = new JTextField();
	private JTextField solPyroB = new JTextField();
	private JTextField visPyroB = new JTextField();
	private JTextField omberB = new JTextField();
	private JTextField silOmberB = new JTextField();
	private JTextField golOmberB = new JTextField();
	private JTextField kernB = new JTextField();
	private JTextField lumKernB = new JTextField();
	private JTextField firKernB = new JTextField();
	private JTextField jaspB = new JTextField();
	private JTextField purJaspB = new JTextField();
	private JTextField priJaspB = new JTextField();	
	private JTextField hemoB = new JTextField();
	private JTextField vivHemoB = new JTextField();
	private JTextField radHemoB = new JTextField();
	private JTextField hedbB = new JTextField();
	private JTextField vitHedbB = new JTextField();
	private JTextField glaHedbB = new JTextField();
	private JTextField gneiB = new JTextField();
	private JTextField iriGneiB = new JTextField();
	private JTextField priGneiB = new JTextField();
	private JTextField dochB = new JTextField();
	private JTextField onyOchB = new JTextField();
	private JTextField obsOchB = new JTextField();
	private JTextField spodB = new JTextField();
	private JTextField briSpodB = new JTextField();
	private JTextField gleSpodB = new JTextField();
	private JTextField crokB = new JTextField();
	private JTextField shaCrokB = new JTextField();
	private JTextField cryCrokB = new JTextField();
	private JTextField bistB = new JTextField();
	private JTextField triBistB = new JTextField();
	private JTextField monBistB = new JTextField();
	private JTextField arkoB = new JTextField();
	private JTextField criArkoB = new JTextField();
	private JTextField priArkoB = new JTextField();
	private JTextField mercB = new JTextField();
	private JTextField magMercB = new JTextField();
	private JTextField vitMercB = new JTextField();
	private JTextField tritB = new JTextField();
	private JTextField pyerB = new JTextField();
	private JTextField mexaB = new JTextField();
	private JTextField isogB = new JTextField();
	private JTextField nocxB = new JTextField();
	private JTextField zydrB = new JTextField();
	private JTextField megaB = new JTextField();
	private JTextField morpB = new JTextField();

	NIMGUI() {
		makeMenus();
		makeCalcPanels();
		makeLayoutPanels();
		setJMenuBar(myMenu);
		add(overallLayoutPanel);
		
	}
	private void makeCalcPanels() {
		//Veldspar Panel
		veldPanel = new JPanel();
		veldPanel.setBorder(new TitledBorder(new EtchedBorder(), "Veldspar"));
		veldPanel.setLayout(new GridLayout(3,2));
		veldPanel.setSize(168,131);
		veldPanel.add(veldL);
		veldPanel.add(veldB);
		veldPanel.add(conVeldL);
		veldPanel.add(conVeldB);
		veldPanel.add(denVeldL);
		veldPanel.add(denVeldB);
		
		//Scordite Panel
		scordPanel = new JPanel();
		scordPanel.setBorder(new TitledBorder(new EtchedBorder(), "Scordite"));
		scordPanel.setLayout(new GridLayout(3,2));
		scordPanel.setSize(168,131);
		scordPanel.add(scordL);
		scordPanel.add(scordB);
		scordPanel.add(conScordL);
		scordPanel.add(conScordB);
		scordPanel.add(masScordL);
		scordPanel.add(masScordB);
		
		//Plagioclase Panel
		plagPanel = new JPanel();
		plagPanel.setBorder(new TitledBorder(new EtchedBorder(), "Plagioclase"));
		plagPanel.setLayout(new GridLayout(3,2));
		plagPanel.setSize(168,131);
		plagPanel.add(plagL);
		plagPanel.add(plagB);
		plagPanel.add(azuPlagL);
		plagPanel.add(azuPlagB);
		plagPanel.add(ricPlagL);
		plagPanel.add(ricPlagB);
		
		//Pyroxeres Panel
		pyroPanel = new JPanel();
		pyroPanel.setBorder(new TitledBorder(new EtchedBorder(), "Pyroxeres"));
		pyroPanel.setLayout(new GridLayout(3,2));
		pyroPanel.setSize(168,131);
		pyroPanel.add(pyroL);
		pyroPanel.add(pyroB);
		pyroPanel.add(solPyroL);
		pyroPanel.add(solPyroB);
		pyroPanel.add(visPyroL);
		pyroPanel.add(visPyroB);
		
		//Omber Panel
		omberPanel = new JPanel();
		omberPanel.setBorder(new TitledBorder(new EtchedBorder(), "Omber"));
		omberPanel.setLayout(new GridLayout(3,2));
		omberPanel.setSize(168,131);
		omberPanel.add(omberL);
		omberPanel.add(omberB);
		omberPanel.add(silOmberL);
		omberPanel.add(silOmberB);
		omberPanel.add(golOmberL);
		omberPanel.add(golOmberB);
		
		//Kernite Panel
		kernPanel = new JPanel();
		kernPanel.setBorder(new TitledBorder(new EtchedBorder(), "Kernite"));
		kernPanel.setLayout(new GridLayout(3,2));
		kernPanel.setSize(168,131);
		kernPanel.add(kernL);
		kernPanel.add(kernB);
		kernPanel.add(lumKernL);
		kernPanel.add(lumKernB);
		kernPanel.add(firKernL);
		kernPanel.add(firKernB);
		
		//Jaspet Panel
		jaspPanel = new JPanel();
		jaspPanel.setBorder(new TitledBorder(new EtchedBorder(), "Jaspet"));
		jaspPanel.setLayout(new GridLayout(3,2));
		jaspPanel.setSize(168,131);
		jaspPanel.add(jaspL);
		jaspPanel.add(jaspB);
		jaspPanel.add(purJaspL);
		jaspPanel.add(purJaspB);
		jaspPanel.add(priJaspL);
		jaspPanel.add(priJaspB);
		
		//Hemorphite Panel
		hemoPanel = new JPanel();
		hemoPanel.setBorder(new TitledBorder(new EtchedBorder(), "Hemorphite"));
		hemoPanel.setLayout(new GridLayout(3,2));
		hemoPanel.setSize(168,131);
		hemoPanel.add(hemoL);
		hemoPanel.add(hemoB);
		hemoPanel.add(vivHemoL);
		hemoPanel.add(vivHemoB);
		hemoPanel.add(radHemoL);
		hemoPanel.add(radHemoB);
		
		//Hedbergite Panel
		hedbPanel = new JPanel();
		hedbPanel.setBorder(new TitledBorder(new EtchedBorder(), "Hedbergite"));
		hedbPanel.setLayout(new GridLayout(3,2));
		hedbPanel.setSize(168,131);
		hedbPanel.add(hedbL);
		hedbPanel.add(hedbB);
		hedbPanel.add(vitHedbL);
		hedbPanel.add(vitHedbB);
		hedbPanel.add(glaHedbL);
		hedbPanel.add(glaHedbB);
		
		//Gneiss Panel
		gneiPanel = new JPanel();
		gneiPanel.setBorder(new TitledBorder(new EtchedBorder(), "Gneiss"));
		gneiPanel.setLayout(new GridLayout(3,2));
		gneiPanel.setSize(168,131);
		gneiPanel.add(gneiL);
		gneiPanel.add(gneiB);
		gneiPanel.add(iriGneiL);
		gneiPanel.add(iriGneiB);
		gneiPanel.add(priGneiL);
		gneiPanel.add(priGneiB);
		
		//Dark Ochre Panel
		dochPanel = new JPanel();
		dochPanel.setBorder(new TitledBorder(new EtchedBorder(), "Dark Ochre"));
		dochPanel.setLayout(new GridLayout(3,2));
		dochPanel.setSize(168,131);
		dochPanel.add(dochL);
		dochPanel.add(dochB);
		dochPanel.add(onyOchL);
		dochPanel.add(onyOchB);
		dochPanel.add(obsOchL);
		dochPanel.add(obsOchB);
		
		//Spodumain Panel
		spodPanel = new JPanel();
		spodPanel.setBorder(new TitledBorder(new EtchedBorder(), "Spodumain"));
		spodPanel.setLayout(new GridLayout(3,2));
		spodPanel.setSize(168,131);
		spodPanel.add(spodL);
		spodPanel.add(spodB);
		spodPanel.add(briSpodL);
		spodPanel.add(briSpodB);
		spodPanel.add(gleSpodL);
		spodPanel.add(gleSpodB);
		
		//Crokite Panel
		crokPanel = new JPanel();
		crokPanel.setBorder(new TitledBorder(new EtchedBorder(), "Crokite"));
		crokPanel.setLayout(new GridLayout(3,2));
		crokPanel.setSize(168,131);
		crokPanel.add(crokL);
		crokPanel.add(crokB);
		crokPanel.add(shaCrokL);
		crokPanel.add(shaCrokB);
		crokPanel.add(cryCrokL);
		crokPanel.add(cryCrokB);
		
		//Bistot Panel
		bistPanel = new JPanel();
		bistPanel.setBorder(new TitledBorder(new EtchedBorder(), "Bistot"));
		bistPanel.setLayout(new GridLayout(3,2));
		bistPanel.setSize(168,131);
		bistPanel.add(bistL);
		bistPanel.add(bistB);
		bistPanel.add(triBistL);
		bistPanel.add(triBistB);
		bistPanel.add(monBistL);
		bistPanel.add(monBistB);
		
		//Arkonor Panel
		arkoPanel = new JPanel();
		arkoPanel.setBorder(new TitledBorder(new EtchedBorder(), "Arkonor"));
		arkoPanel.setLayout(new GridLayout(3,2));
		arkoPanel.setSize(168,131);
		arkoPanel.add(arkoL);
		arkoPanel.add(arkoB);
		arkoPanel.add(criArkoL);
		arkoPanel.add(criArkoB);
		arkoPanel.add(priArkoL);
		arkoPanel.add(priArkoB);
		
		//Mercoxit Panel
		mercPanel = new JPanel();
		mercPanel.setBorder(new TitledBorder(new EtchedBorder(), "Mercoxit"));
		mercPanel.setLayout(new GridLayout(3,2));
		mercPanel.setSize(168,131);
		mercPanel.add(mercL);
		mercPanel.add(mercB);
		mercPanel.add(magMercL);
		mercPanel.add(magMercB);
		mercPanel.add(vitMercL);
		mercPanel.add(vitMercB);
		
		//Result Panel
		resultPanel = new JPanel();
		resultPanel.setBorder(new TitledBorder(new EtchedBorder(), "Results"));
		resultPanel.setLayout(new GridLayout(10,2));
		resultPanel.add(tritL);
		resultPanel.add(tritRL);
		resultPanel.add(pyerL);
		resultPanel.add(pyerRL);
		resultPanel.add(mexaL);
		resultPanel.add(mexaRL);
		resultPanel.add(isogL);
		resultPanel.add(isogRL);
		resultPanel.add(nocxL);
		resultPanel.add(nocxRL);
		resultPanel.add(zydrL);
		resultPanel.add(zydrRL);
		resultPanel.add(megaL);
		resultPanel.add(megaRL);
		resultPanel.add(morpL);
		resultPanel.add(morpRL);
		resultPanel.add(tritN);
		resultPanel.add(tritB);
		resultPanel.add(pyerN);
		resultPanel.add(pyerB);
		resultPanel.add(mexaN);
		resultPanel.add(mexaB);
		resultPanel.add(isogN);
		resultPanel.add(isogB);
		resultPanel.add(nocxN);
		resultPanel.add(nocxB);
		resultPanel.add(zydrN);
		resultPanel.add(zydrB);
		resultPanel.add(megaN);
		resultPanel.add(megaB);
		resultPanel.add(morpN);		
		resultPanel.add(morpB);
		resultPanel.add(minerPayN);
		resultPanel.add(minerPayRL);
		resultPanel.add(haulerPayN);
		resultPanel.add(haulerPayRL);
		
	}

	
	private void makeLayoutPanels() {
		overallLayoutPanel = new JPanel();
		overallLayoutPanel.setLayout(new BorderLayout());
		centerLayoutPanel = new JPanel();
		centerLayoutPanel.setLayout(new GridLayout(4, 4));
		centerLayoutPanel.setSize(675,525);
		centerLayoutPanel.setBorder(new TitledBorder(new EtchedBorder(), "Ore Amounts"));
		centerLayoutPanel.add(veldPanel);
		centerLayoutPanel.add(scordPanel);
		centerLayoutPanel.add(plagPanel);
		centerLayoutPanel.add(pyroPanel);
		centerLayoutPanel.add(omberPanel);
		centerLayoutPanel.add(kernPanel);
		centerLayoutPanel.add(jaspPanel);
		centerLayoutPanel.add(hemoPanel);
		centerLayoutPanel.add(hedbPanel);
		centerLayoutPanel.add(gneiPanel);
		centerLayoutPanel.add(dochPanel);
		centerLayoutPanel.add(spodPanel);
		centerLayoutPanel.add(crokPanel);
		centerLayoutPanel.add(bistPanel);
		centerLayoutPanel.add(arkoPanel);
		centerLayoutPanel.add(mercPanel);
		overallLayoutPanel.add(resultPanel, BorderLayout.CENTER);
		overallLayoutPanel.add(centerLayoutPanel, BorderLayout.NORTH);


	}
		private void makeMenus() {
		myMenu = new JMenuBar();
		fileMenu = new JMenu("File");
		optionMenu = new JMenu("Options");
		stations = new JMenu("Station");
		helpMenu = new JMenu("Help");
		calculate = new JMenuItem("Calculate");
		fileExit = new JMenuItem("Exit");
		helpAbout = new JMenuItem("About...");
		halibai = new JRadioButtonMenuItem("Halibai");
		sonama = new JRadioButtonMenuItem("Sonama");
		turba = new JRadioButtonMenuItem("Turba");
		inisIlix = new JRadioButtonMenuItem("Inis Ilix");
		hilaban = new JRadioButtonMenuItem("Hilaban");
		kothe = new JRadioButtonMenuItem("Kothe");
		aunia = new JRadioButtonMenuItem("Aunia");
		hauler = new JCheckBoxMenuItem("Hauler?");
		
		fileMenu.add(calculate);
		fileMenu.add(fileExit);
		optionMenu.add(hauler);
		optionMenu.add(stations);
		stations.add(halibai);
		stations.add(sonama);
		stations.add(turba);
		stations.add(inisIlix);
		stations.add(hilaban);
		stations.add(kothe);
		stations.add(aunia);
		helpMenu.add(helpAbout);
		myMenu.add(fileMenu);
		myMenu.add(optionMenu);
		myMenu.add(helpMenu);
		
	}
}